import { SelectControlSchema } from 'amis/lib/renderers/Form/Select'
import amisUtils from '@/components/amis/amisUtils'
import BaseEnum from '@/core/utils/BaseEnum'

export type BaseEnumSelectUtilsProps = SelectControlSchema & {
	baseEnum: BaseEnum<any>
}

class BaseEnumSelectUtils {
	getSchema = (parmas: BaseEnumSelectUtilsProps): SelectControlSchema => {
		const mergeSchema = Object.assign(
			{
				type: 'select',
				clearable: true,
				options: amisUtils.getSelectOptionsFromBaseEnum(parmas.baseEnum),
			},
			parmas,
		)

		const schema = mergeSchema as SelectControlSchema
		return schema
	}
}

export default new BaseEnumSelectUtils()
